#pragma once

#include <string>
using namespace std;

#include "LogExecutor.h"
#include "Spinlock.h"

namespace Utility
{
    namespace LoggerLib
    {
        class CFileExecutor : public IExecutor
        {
        public:
            CFileExecutor(const wstring& strName);
            ~CFileExecutor(void);

        public:
            virtual bool DoLogging(const LoggingEvent& event);
            virtual bool Reopen();
            virtual void Close();

        public:
            void SetFilePath(const wstring& strPath);
            bool OpenFile();

        private:
            void UpdateDate();

        private:
            wstring m_strFilePath;
            HANDLE m_hFile;
            SYSTEMTIME m_stFileTime;
            CAutoSpinLock m_lockFile;
            CAutoSpinLock m_lockFilePath;
        };
    }
}
